<?php
if (isset($_POST['id'])){
    include 'config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $condOrder=' order by workyear desc ';
    if (isset($_POST['oid'])){
        if(1 == $_POST['oid']){
            $condOrder=' order by workyear desc ';
        }
        if(2 == $_POST['oid']){
            $condOrder=' order by id desc ';
        }
    }
    if (99 == $_POST['id']){
        $query=$mysqli->query("SELECT workyear,id,title,photo,subtitle,star,price FROM zhi_supplier ".$condOrder);
    }else{
        $query=$mysqli->query("SELECT workyear,id,title,photo,subtitle,star,price FROM zhi_supplier where skill_type=".$_POST['id']." ".$condOrder);
    }
    $data=array();
    while ($list=$query->fetch_assoc()){
        $price=(int)$list['price'];
        if(0 == $price){
            $list['price']=0;
        }
        $data[]=array('workyear'=>$list['workyear'],'id'=>$list['id'],'title'=>$list['title'],'photo'=>$list['photo'],
            'subtitle'=>$list['subtitle'],'star'=>$list['star'],'price'=>$list['price']);
    }
    $mysqli->close();
    echo json_encode($data);
}

